﻿using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using studentSubsidy.Entity.User;

[ApiController]
[Route("api/[Action]")]
public class JwtController
{

    public TokenOptions TokenOptions { get; }

    public JwtController(IOptions<TokenOptions> options)
    {
        TokenOptions  = options.Value;
    }
    
    [HttpGet(Name = "token")]
    public string Token()
    {
        return new JwtUtils(TokenOptions).CreateTokenAsync("Leety", "admin");
    }
    
    [HttpPost(Name = "checkToken")]
    [Authorize]
    public LoginResult checkToken([FromHeader] string Authorization)
    {
        return new LoginResult(200, "", "",null);
    }
    
}